package com.kgcx.common.rabbitmq.producer;

import com.alibaba.fastjson.JSONObject;
import com.kgcx.common.client.organization.pojo.CustomerMsg;
import com.kgcx.common.rabbitmq.consts.ExchangeConst;
import com.kgcx.common.rabbitmq.consts.RoutingKeyConst;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CustomerMsgProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Async
    public void customerMsgSend(CustomerMsg customerMsg) {
        log.info(String.format("发送乘客站内消息的MQ消息。"));

        rabbitTemplate.convertAndSend(ExchangeConst.MSG, RoutingKeyConst.CUSTOMER_MSG_SEND, JSONObject.toJSONString(customerMsg));

    }
}
